import requests


def send_to_dingding(webhook, content):
    """
    发送钉钉消息-text
    :param webhook:
    :param content:
    :return:
    """
    headers = {"Content-Type": "application/json ;charset=utf-8"}
    data = {
        "msgtype": "text",
        "text": {"content": content, "at": {"isAtAll": False}}
    }
    res = requests.post(url=webhook, json=data, headers=headers)
    print("发送钉钉消息，返回结果:", res.text)


if __name__ == '__main__':
    webhook = 'https://oapi.dingtalk.com/robot/send?access_token=041784954d036784be74c54c5c3f09a503df3adb56ca08b788d3dacf27cd0fe9'
    send_to_dingding(webhook, "leopold测试")
